import logo from "./logo.svg";
import "./App.css";
import { useEffect, useState } from "react";
import store from "./store";
import { decrement, increment, incrementAsync } from "./store/actions";
import { useSelector, useDispatch } from "react-redux";

function App() {
  //   const [num, setNum] = useState(store.getState().num)

  const num = useSelector((state) => state.num);
  //  console.log(num);
  const dispatch = useDispatch();

  //   useEffect(()=>{

  //     const unsubscribe = store.subscribe(()=>{
  //         setNum(store.getState().num)
  //      })

  //      return ()=>{
  //         unsubscribe()
  //      }

  //   }, [])

  // const incrementHandle = ()=>{
  //     store.dispatch(incrementAsync({ mobile:13911111111,code:"HM@gk2#4" }))
  // }

  const decrementHandle = () => {
    //   store.dispatch(decrement(5))
    dispatch(decrement(5));
  };
  return (
    <div className="App">
      <h2>Num {num}</h2>
      {/* <button onClick={incrementHandle}>increment</button> */}
      <button onClick={decrementHandle}>decrement</button>
    </div>
  );
}

export default App;
